<?php
defined('BASEPATH') or exit('No direct script access allowed');
?>
<!DOCTYPE html>
<html lang="en">

<head>
	<!--加载header文件-->
	<?php
	include_once 'public/views/header.php';
	?>
	<?php
	include_once 'public/home/html/faltSelect.php';
	include_once 'public/home/html/laydate.php';
	include_once 'public/home/html/upload.php';
	include_once 'public/home/html/onoff.php'
	?>
	<link rel="stylesheet" href="public/css/edit.css" />
	<script src="cust/js/communicationEdit.js?v=20240123"></script>
	<script src="cust/js/goodsUpload.js"></script>
	<script src="public/js/cus_modal.js"></script>
	<style type="text/css">
		.edit_table{
			font-size:16px;
		}
		.file {
			position: relative;
			display: inline-block;
			background: #D0EEFF;
			border: 1px solid #99D3F5;
			border-radius: 4px;
			padding: 4px 12px;
			overflow: hidden;
			color: #1E88C7;
			text-decoration: none;
			text-indent: 0;
			line-height: 20px;
		}

		.file input {
			position: absolute;
			font-size: 100px;
			right: 0;
			top: 0;
			opacity: 0;
		}

		.file:hover {
			background: #AADFFD;
			border-color: #78C3F3;
			color: #004974;
			text-decoration: none;
		}

		.showFileName,
		.fileerrorTip {
			position: relative;
			top: 5px;
			left: 5px;
		}

		.fileerrorTip {
			color: red;
		}

		.showFileName {
			color: green;
		}

		.del-icon {
			color: red;
			position: relative;
			left: 15px;
		}

		/* 新增 */
		.data-box {
			width: 100px;
			height: 100px;
			border-radius: 4px;
			float: left;
			margin: 10px;
			padding: 10px;
			cursor: pointer;
			position: relative;
		}

		.tab-item .data-box:nth-child(1) {
			width: 100px !important;
		}

		.data-box:hover {
			background-color: #ccc;
		}

		.data-box:hover>.banner-prev,
		.data-box:hover>.banner-next,
		.data-box:hover>.del-icon-img {
			display: block;
			-webkit-animation: spopIn 0.2s ease-in-out;
			animation: spopIn 0.2s ease-in-out;
		}

		.add-img {
			height: 80px;
			width: 80px;
			border-radius: 4px;
		}

		.document-img {
			height: 80px;
			width: 80px;
			border-radius: 4px;
		}

		.del-icon-img {
			position: absolute;
			font-size: 25px;
			color: #dd2727;
			right: 0px;
			top: 0px;
			cursor: pointer;
		}

		.data-box-banner .del-icon-img {
			position: absolute;
			font-size: 25px;
			color: #dd2727;
			right: 0px;
			top: 0px;
			cursor: pointer;
			display: none;
		}

		.banner-prev,
		.banner-next {
			height: 20px;
			width: 20px;
			background-color: #999;
			text-align: center;
			line-height: 20px;
			color: white;
			position: absolute;
			font-size: 12px;
			top: 40px;
			border-radius: 2px;
			display: none;
		}

		.banner-prev {
			left: 0px;
		}

		.banner-next {
			right: 0px;
		}

		.file {
			float: left;
		}

		.file-demo {
			float: left;
			margin-right: 50px;
		}

		.add-icon {
			font-size: 20px;
			color: #1FC91C;
			position: relative;
			top: 3px;
			cursor: pointer;
		}

		.del-icon {
			font-size: 16px;
			color: #dd2727;
			cursor: pointer;
		}

	</style>
</head>

<body>
	<!-- 新增 -->
	<!-- 图片demo -->
	<div class="data-box-demo hide">
		<div class="data-box data-box-banner">
			<i class="icon-remove-sign  del-icon-img" onclick="delImg(this)"></i>
			<a href="" download=""><img src="" alt="" class="document-img"></a>
			<input type="hidden" class="path">
			<input type="hidden" class="icon">

			<!-- 前后 -->
			<div class="banner-prev" onclick="bannerPrev(this)"><i class="fa fa-angle-left" aria-hidden="true"></i></div>
			<div class="banner-next" onclick="bannerNext(this)"><i class="fa fa-angle-right" aria-hidden="true"></i></div>
		</div>
	</div>
	<!-- 图片数据存储 -->
	<input type="file" id="upload_img" style="display: none;">
	<!-- 文件数据存储 -->
	<input type="file" id="filename" style="display: none;" />
	<!-- 添加成员demo -->
	<div class="member-demo hide">
		<div class="member-tr-in">
			<select style="width:120px" id="identity" class="identity" dataType="*" data-val="<?= estr($detail, 'identity') ?>" name="identity[]" onchange="change(this)">
				<option value="-1">请选择身份</option>
				<?php foreach ($identity_arr as $k => $v) : ?>
					<option value="<?php echo $v['Value']; ?>" ><?php echo $v['Caption']; ?></option>
				<?php endforeach; ?>
			</select>
			<input type="text" id="author" class="author" value="<?= estr($detail, 'author') ?>" dataType="*" placeholder="请输入工号或者学号" />
			<input type="text" name="author_name[]" id="author_name" style="width: 20%;" readonly class="author_name" value="<?= estr($detail, 'author') ?>" dataType="*" placeholder="请输入姓名" />
			<input type="text" name="author_id[]" class="author-id" style="display: none;" />
			<i class="icon-remove-sign del-icon" onclick="delStudent(this)"></i>
		</div>
	</div>
	<!-- 新增结束 -->
	<div class="container">
		<div class="row">
			<input type="hidden" id="modal_title" value="<?= $title ?>" />
			<input type="hidden" id="modal_height" value="450" />
			<input type="hidden" id="now_type" value="paperFile" />
			<input type="hidden" id="can_audit" value="<?=$can_audit?>" />
			<input type="hidden" id="can_save" value="<?=$can_save?>" />
			<input type="hidden" id="type" value="<?=ResultsType::Tenth[XPHEnum::Value]?>" />
			<input type="hidden" id="can_pass" value="<?=$can_pass?>" />
			<input type="hidden" id="can_refused" value="<?=$can_refused?>" />
			<form id="editForm" enctype="multipart/form-data">
			<input type="hidden" id="status" name="status" value="<?= estr($detail, 'status') ?>" />
				<input type="hidden" id="save_type" name="save_type" value="" />
				<input type="hidden" id="id" name="id" value="<?= $id ?>" />
				<table class='edit_table'>
					<tr>
						<th class="required">会议名称<span class="required">*</span></th>
						<td>
							<input type="text" style="width:70%;" name="name" id="name" value="<?= estr($detail, 'name') ?>" dataType="*" />
						</td>
						<th class="required">地点<span class="required">*</span></th>
						<td>
							<input type="text" style="width:70%;" name="adress" id="adress" value="<?= estr($detail, 'adress') ?>" dataType="*" />
						</td>
					</tr>
					<tr>
						<th class="required">业绩（成果）归属年份<span class="required">*</span></th>
						<td>
							<input type="text" name="award_year" id="award_year" value="<?= estr($detail, 'award_year') ?>" dataType="*" />
						</td>
						<th class="required">举办日期<span class="required">*</span></th>
						<td>
							<input type="text" name="time" id="time" value="<?= estr($detail, 'time') ?>" dataType="*" />
						</td>
					</tr>
					<tr>
						<th class="required">本校参加人次<span class="required">*</span></th>
						<td>
							<input type="number" name="person_time" id="person_time" value="<?= estr($detail, 'person_time') ?>" dataType="*" />
						</td>
						<th class="required">提交论文篇数</th>
						<td>
							<input type="number" name="paper_num" id="paper_num" value="<?= estr($detail, 'paper_num') ?>" />
						</td>
					</tr>
					<tr>
						<th class="required">主办单位<span class="required">*</span></th>
						<td>
							<input type="text" style="width:70%;" name="organizer_dept" id="organizer_dept" value="<?= estr($detail, 'organizer_dept') ?>" dataType="*" />
						</td>
						<th class="required">参加形式<span class="required">*</span></th>
						<td>
							<select style="width:157px" id="join_type" dataType="*" data-val="<?= estr($detail, 'join_type') ?>" name="join_type">
								<option value="-1">请选择</option>
								<?php foreach ($join_type_arr as $k => $v) : ?>
									<option value="<?php echo $v; ?>" <?php if ($v == $detail['join_type']) echo 'selected="selected"'; ?>><?php echo $v; ?></option>
								<?php endforeach; ?>
							</select>
						</td>
					</tr>
					<tr class="member-tr">
						<th class="required">参加人员<span class="required">*</span>
							<i class="icon-plus-sign add-icon" onclick="addStudent()"></i>
						</th>
						<td colspan="3">
							<?php if (isset($detail) && $author) : ?>
								<?php foreach ($author as $k => $v) : ?>
									<div class="member-tr-in">
										<select style="width:120px" class="identity" dataType="*" data-val="<?= $v['identity'] ?>" name="identity[]" onchange="change(this)">
											<option value="-1">请选择身份</option>
											<?php foreach ($identity_arr as $k1 => $v1) : ?>
												<option value="<?php echo $v1['Value']; ?>" <?php if ($v1['Value'] == $v['identity']) echo 'selected="selected"'; ?>><?php echo $v1['Caption']; ?></option>
											<?php endforeach; ?>
										</select>
										<input type="text"  class="author" value="<?= $v['usercode'] ?>" <?php if ($v['identity'] == 3) echo 'style="display: none;"'; ?> dataType="*" data-index="0" placeholder="请输入工号或者学号" />
										<input type="text" name="author_name[]" style="width:20%;" class="author_name <?php if ($v['identity'] == 3) echo 'author'; ?>"  value="<?= $v['author_name'] ?>" dataType="*" data-index="0" <?php if ($v['identity'] != 3) echo ' readonly'; ?>  placeholder="请输入姓名"/>
										<input type="text" name="author_id[]" class="author-id" style="display: none;" value="<?= $v['author_id'] ?>" />
										<i class="icon-remove-sign del-icon" onclick="delStudent(this)"></i>
									</div>
								<?php endforeach ?>
							<?php else : ?>
								<div class="member-tr-in">
									<select style="width:120px" class="identity" dataType="*" data-val="" name="identity[]" onchange="change(this)">
										<option value="-1">请选择身份</option>
										<?php foreach ($identity_arr as $k => $v) : ?>
											<option value="<?php echo $v['Value']; ?>" ><?php echo $v['Caption']; ?></option>
										<?php endforeach; ?>
									</select>
									<input type="text"  class="author" value=""  dataType="*" data-index="0" placeholder="请输入工号或者学号" />
									<input type="text" name="author_name[]" style="width: 20%;" class="author_name"  value="" dataType="*"  readonly data-index="0" placeholder="请输入姓名" />
									<input type="text" name="author_id[]" class="author-id"  style="display: none;" />
								</div>
							<?php endif ?>
						</td>
					</tr>
					<tr>
						<th class="required">所属单位<span class="required">*</span></th>
						<td>
							<select style="width:157px" id="dept_name" dataType="*" data-val="<?= estr($detail, 'dept_name') ?>" name="dept_name">
								<option value="-1">请选择</option>
								<?php foreach ($dept_name_arr as $k => $v) : ?>
									<option value="<?php echo $v; ?>" <?php if ($v == $detail['dept_name']) echo 'selected="selected"'; ?>><?php echo $v; ?></option>
								<?php endforeach; ?>
							</select>
						</td>
						<th class="required">类别</th>
						<td>
							<select style="width:157px" id="type" data-val="<?= estr($detail, 'type') ?>" name="type">
								<option value="-1">请选择</option>
								<?php foreach ($type_arr as $k => $v) : ?>
									<option value="<?php echo $v; ?>" <?php if ($v == $detail['type']) echo 'selected="selected"'; ?>><?php echo $v; ?></option>
								<?php endforeach; ?>
							</select>
						</td>
						<!-- <th class="required">参加人员<span class="required">*</span></th>
						<td>
							<input type="text" name="participants" id="participants" value="<?= estr($detail, 'participants') ?>" dataType="*" />
						</td> -->
					</tr>
					
					<!-- <tr> -->
						<!-- <th class="required">类别</th>
						<td>
							<select style="width:157px" id="type" data-val="<?= estr($detail, 'type') ?>" name="type">
								<option value="-1">请选择</option>
								<?php foreach ($type_arr as $k => $v) : ?>
									<option value="<?php echo $v; ?>" <?php if ($v == $detail['type']) echo 'selected="selected"'; ?>><?php echo $v; ?></option>
								<?php endforeach; ?>
							</select>
						</td> -->
						<!-- <th class="required">业绩分</th>
						<td>
							<input type="number" name="performance_score" id="performance_score" value="<?= estr($detail, 'performance_score') ?>" />
						</td> -->
					<!-- </tr> -->
					<tr>
						<th class="required">考核等级<span class="required">*(仅限业绩审核分类使用，不涉及其他场景)</span></th>
						<td>
							<!-- <input type="text" name="level" id="level" value="<?= estr($detail, 'examine_level') ?>" dataType="*" /> -->
							<select style="width:157px" id="examine_level" dataType="*" data-val="<?= estr($detail, 'examine_level') ?>" name="examine_level">
								<option value="-1">请选择</option>
								<?php foreach ($examine_level_arr as $k => $v) : ?>
									<option value="<?php echo $v; ?>" <?php if ($v == $detail['examine_level']) echo 'selected="selected"'; ?>><?php echo $v; ?></option>
								<?php endforeach; ?>
							</select>
						</td>
						<th class="required">是否提交科研奖励<span class="required">*</span></th>
						<td>
							<select style="width:157px" id="is_submit_cg" dataType="*" data-val="<?= estr($detail, 'is_submit_cg') ?>" name="is_submit_cg">
								<option value="-1">请选择</option>
							
								<?php foreach ($is_submit_cg_arr as $k => $v) : ?>
									<?php if (!isset($detail['is_submit_cg'])) : ?>
										<option value="<?php echo $v['Value']; ?>" ><?php echo $v['Caption']; ?></option>
									<?php else : ?>
										<option value="<?php echo $v['Value']; ?>" <?php if ($v['Value'] == $detail['is_submit_cg']) echo 'selected="selected"'; ?>><?php echo $v['Caption']; ?></option>		
									<?php endif ?>
								<?php endforeach; ?>
							
							</select>
						</td>
					</tr>
					<tr>
						<th class="required">图片（png,jpg,jpeg,gif）<span class="required">*(图片或附件必需上传一个)</span></th>
						<td colspan="3">
							<!-- <input type="hidden" name="img" value="<?= estr($detail, 'img') ?>" id="img">
							<img src="<?php echo $detail['img'] ? $detail['img'] : 'cust/images/upload.png'; ?>" alt="" style="width:150px; height:70px; cursor: pointer;" onclick="$(this).next().click();">
							<input type="file" style="display: none;" name="image_file" onchange="doImage(this);"> -->
							<!-- 新增 -->
							<div class="img-box">
								<div class="data-box">
								    <img class="add-img" data-type="7" src="public/home/images/add-structure.png" alt="" onclick="upload(this)">
								</div>
								<?php if(isset($detail['img'])): ?>
									<?php foreach ($detail['img'] as $k => $v):?>
											<div class="data-box data-box-banner">
												<i class="icon-remove-sign  del-icon-img" onclick="delImg(this)"></i>
												<a href="<?=$v['src'] ?>" download=""><img src="<?=$v['src'] ?>" alt="" class="document-img"></a>
												<input type="hidden" class="path"  name="img[]" value="<?=$v['src'] ?>">

												<!-- 前后 -->
												<div class="banner-prev" onclick="bannerPrev(this)"><i class="fa fa-angle-left" aria-hidden="true"></i></div>
												<div class="banner-next" onclick="bannerNext(this)"><i class="fa fa-angle-right" aria-hidden="true"></i></div>
											</div>										
									<?php endforeach ?>
								<?php endif ?>
							</div>
							<!-- 新增结束 -->
						</td>
					</tr>

					<tr>
						<th class="required">附件（pdf）<span class="required">*(图片或附件必需上传一个)</span></th>
						<td colspan="3">
							<!-- <a href="javascript:;" class="file">选择文件
								<input type="file" name="filename" id="filename" />
								<input type="hidden" name="files" id="files" value="<?= estr($detail, 'filename') ?>" />
								<input type="hidden" id="files_id" value="<?= estr($detail, 'file_id') ?>" />
							</a>
							<a href="<?php echo base_url() . $detail['filename'] ?>"><span class="showFileName"><?= estr($detail, 'new_filename') ?></span></a><i class="icon-remove-sign del-icon" style="display: none;" onclick="delDocument(this)"></i>
							<span class="fileerrorTip"></span> -->
							<!-- 新增 -->
							<div class="file_demo">
								<a href="javascript:;" class="file" onclick="upload1()">添加文件
								</a>
								<div>
									<?php if(isset($detail['file'])): ?>
										<?php foreach ($detail['file'] as $k => $v): ?>
											
												<!-- <div class="showFileName"><span><?=$v['filename']?></span><i class="icon-remove-sign del-icon" style="display: none;" onclick="delFile(this)"></i>
													<input type="hidden" name="files[]" value="<?=$v['src']?>">
												</div> -->

												<div class="file-demo"><a href="<?php echo base_url() . $v['src'] ?>"><span class="showFileName"><?=$v['filename']?><input type="hidden" name="files[]" value="<?=$v['src']?>"></span></a><i class="icon-remove-sign del-icon" style="" onclick="delFile(this)"></i></div>
											
										<?php endforeach ?>
									<?php endif ?>
								</div>
								<span class="fileerrorTip"></span>
							</div>
							<!-- 新增结束 -->
						</td>

					</tr>

				</table>
			</form>

		</div>
		<!-- 所有作者信息填写 -->
		<div class="edit-mask">
			<!-- 科研人员（教师）基本信息 -->
			<div class="edit-msg-container teacher-msg">
				<form id="editTeacherForm" enctype="multipart/form-data">
					<div class="layui-layer-title edit-title">科研人员（教师）基本信息填写</div>

					<table class='edit_table'>
						<tr>
							<th class="required">姓名<span class="required">*</span></th>
							<td>
								<input type="text" id="username_t" value="" dataType="*" />
							</td>
							<th class="required">人事单位<span class="required">*</span></th>
							<td>
								<input type="text" id="personnel_dept_t" value="" dataType="*" />
							</td>
						</tr>
						<tr>
							<th class="required">教工号<span class="required">*</span></th>
							<td>
								<input type="text" id="usercode_t" value="" dataType="*" />
							</td>
							<th class="required">手机号<span class="required">*</span></th>
							<td>
								<input type="text" id="phone_t" value="" dataType="*" />
							</td>
						</tr>
						<tr>
							<th class="required">职称<span class="required">*</span></th>
							<td>
								<input type="text" id="title_t" value="" dataType="*" />
							</td>
							<th class="required">所属单位<span class="required">*</span></th>
							<td>
								<!-- <input type="text" id="dept_name_t" value="" dataType="*" /> -->
								<select style="width:157px" id="dept_name_t" dataType="*" data-val="<?= estr($detail, 'dept_name') ?>">
									<option value="-1">请选择</option>
									<?php foreach ($dept_name_arr as $k => $v) : ?>
										<option value="<?php echo $v; ?>" <?php if ($v == $detail['dept_name']) echo 'selected="selected"'; ?>><?php echo $v; ?></option>
									<?php endforeach; ?>
								</select>
							</td>
						</tr>
						<tr>
							<th class="required">学科背景<span class="required">*</span></th>
							<td>
								<!-- <input type="text" id="academic_background_t" value="" dataType="*" /> -->
								<select style="width:157px" id="academic_background_t" dataType="*" data-val="<?= estr($detail, 'dept_name') ?>">
									<option value="-1">请选择</option>	
									<?php foreach ($subject as $k => $v) : ?>
										<option value="<?php echo $v['name']; ?>" ><?php echo $v['name']; ?></option>
									<?php endforeach; ?>
								</select>
							</td>
							<th class="required">人才称号</th>
							<td>
								<input type="text" id="talent_title_t" value="" />
							</td>
						</tr>
						<tr>
							<th class="required">最高学历</th>
							<td>
								<input type="text" id="max_xl_t" value="" />
							</td>
							<th class="required">最高学位</th>
							<td>
								<input type="text" id="max_xw_t" value="" />
							</td>
						</tr>
						<tr>
							<th class="required">毕业院校</th>
							<td>
								<input type="text" id="graduate_school_t" value="" />
							</td>
							<th class="required">性别</th>
							<td>
								<select style="width:157px" id="sex_t" data-val="">
									<option value="-1">请选择</option>
									<?php foreach ($sex_arr as $k => $v) : ?>
										<option value="<?php echo $v['Caption']; ?>"><?php echo $v['Caption']; ?></option>
									<?php endforeach; ?>
								</select>
							</td>
						</tr>
						<tr>
							<th class="required">出生年月</th>
							<td>
								<input type="text" id="birthday_t" value="" />
							</td>
							<th class="required">研究方向<span class="required">*</span></th>
							<td>
								<input type="text" id="research_direction_t" value="" dataType="*" />
							</td>
						</tr>

					</table>
					<div class="layui-layer-btn layui-layer-btn- edit-btn-group">
						<a class="layui-layer-btn0 save-btn1" style="background-color:#EC6C62; border-color:#EC6C62;" onclick="saveEdit(1)">保存</a>
						<a class="layui-layer-btn0" onclick="cancleEdit()">取消</a>
					</div>
				</form>

			</div>
			<!-- 科研人员（学生）基本信息 -->
			<div class="edit-msg-container student-msg">
				<form id="editStudentForm" enctype="multipart/form-data">
					<div class="layui-layer-title edit-title">科研人员（学生）基本信息填写</div>

					<table class='edit_table'>
						<tr>
							<th class="required">姓名<span class="required">*</span></th>
							<td>
								<input type="text" id="username_s" value="" dataType="*" />
							</td>
							<th class="required">专业<span class="required">*</span></th>
							<td>
								<input type="text" id="major_s" value="" dataType="*" />
							</td>
						</tr>
						<tr>
							<th class="required">年级<span class="required">*</span></th>
							<td>
								<input type="text" id="grade_s" value="" dataType="*" />
							</td>
							<th class="required">班级<span class="required">*</span></th>
							<td>
								<input type="text" id="class_s" value="" dataType="*" />
							</td>
						</tr>
						<tr>
							<th class="required">学号<span class="required">*</span></th>
							<td>
								<input type="text" id="usercode_s" value="" dataType="*" />
							</td>
							<th class="required">手机号<span class="required">*</span></th>
							<td>
								<input type="text" id="phone_s" value="" dataType="*" />
							</td>
						</tr>
						<tr>
							<th class="required">所属单位<span class="required">*</span></th>
							<td>
								<!-- <input type="text" id="dept_name_s" value="" dataType="*" /> -->
								<select style="width:157px" id="dept_name_s" dataType="*" data-val="<?= estr($detail, 'dept_name') ?>">
									<option value="-1">请选择</option>
									<?php foreach ($dept_name_arr as $k => $v) : ?>
										<option value="<?php echo $v; ?>" <?php if ($v == $detail['dept_name']) echo 'selected="selected"'; ?>><?php echo $v; ?></option>
									<?php endforeach; ?>
								</select>
							</td>
							<th class="required">性别</th>
							<td>
								<select style="width:157px" id="sex_s" data-val="">
									<option value="-1">请选择</option>
									<?php foreach ($sex_arr as $k => $v) : ?>
										<option value="<?php echo $v['Caption']; ?>"><?php echo $v['Caption']; ?></option>
									<?php endforeach; ?>
								</select>
							</td>
						</tr>
						<tr>
							<th class="required">出生年月</th>
							<td>
								<input type="text" id="birthday_s" value="" />
							</td>
							<th class="required">研究方向</th>
							<td>
								<input type="text" id="research_direction_s" value="" />
							</td>
						</tr>

					</table>
					<div class="layui-layer-btn layui-layer-btn- edit-btn-group">
						<a class="layui-layer-btn0 save-btn2" style="background-color:#EC6C62; border-color:#EC6C62;" onclick="saveEdit(2)">保存</a>
						<a class="layui-layer-btn0" onclick="cancleEdit()">取消</a>
					</div>
				</form>

			</div>
			<!-- 外校老师基本信息 -->
			<div class="edit-msg-container outside-teacher-msg">
				<form id="editOutsideTeacherForm" enctype="multipart/form-data">
					<div class="layui-layer-title edit-title">外校老师基本信息填写</div>
					<table class='edit_table'>
						<tr>
							<th class="required">姓名<span class="required">*</span></th>
							<td>
								<input type="text" id="username_o" value="" dataType="*" />
							</td>
							<th class="required">工号<span class="required">*</span></th>
							<td>
								<input type="text" id="usercode_o" readonly value="99999999" dataType="*" />
							</td>
						</tr>
						<tr>
							<th class="required">所属单位<span class="required">*</span></th>
							<td>
								<input type="text" id="dept_name_o" value="" dataType="*" />
							</td>
						</tr>

					</table>
					<div class="layui-layer-btn layui-layer-btn- edit-btn-group">
						<a class="layui-layer-btn0 save-btn3" style="background-color:#EC6C62; border-color:#EC6C62;" onclick="saveEdit(3)">保存</a>
						<a class="layui-layer-btn0" onclick="cancleEdit()">取消</a>
					</div>
				</form>

			</div>
		</div>
	</div>
	
</body>

<script type="text/javascript">
	// $(function() {
	// 	show();
	// 	//上传文件
	// 	$(".file").on("change", "input[type='file']", function() {
	// 		var filePath = $(this).val();
	// 		if (filePath.indexOf("jpg") != -1 || filePath.indexOf("png") != -1 || filePath.indexOf("jpeg") != -1) {
	// 			$(".showFileName").html("");
	// 			$(".fileerrorTip").html("请上传文件类型！").show();
	// 			$(".icon-remove-sign").hide();
	// 		} else {
	// 			$(".fileerrorTip").html("").hide();
	// 			doFile(this); //上传图片
	// 		}
	// 		/*else{
	// 			$(".fileerrorTip").html("").hide();
	// 		    var arr=filePath.split('\\');
	// 		    var fileName=arr[arr.length-1];
	// 		    $(".showFileName").html(fileName);
	// 		    return false 
	// 		}*/
	// 	})
	// })

	$(".sumbit").on("click", function() {
		console.log($("form").serialize())
	})

	function change(obj){
		var identity = $(obj).val();
		if(identity == 3){
			$(obj).siblings(".author").removeAttr('dataType');
			$(obj).siblings(".author").hide();
			$(obj).siblings(".author_name").addClass('author')	
			$(obj).siblings(".author_name").removeAttr('readonly');					
		}else if(identity == 2 || identity == 1){
			$(obj).siblings(".author_name").removeClass('author');
	        $(obj).siblings(".author").show();
			$(obj).siblings(".author_name").attr('readonly', 'readonly');
			$(obj).siblings(".author").attr('dataType', '*');
		}
	}

	// 获取焦点
	$('.member-tr').on('focus', '.author', function() {
		var identity = $(this).siblings(".identity").val()
		if (identity == -1) {
			swal({
				title: "提示",
				text: "请先选择身份",
				type: "warning",
				showCancelButton: false,
				closeOnConfirm: true,
				confirmButtonText: "确定",
				confirmButtonColor: "#ec6c62"
			});
		}
	})
	// 失去焦点
	$('.member-tr').on('blur', '.author', function() {
		// console.log('this',$(this))
		var identity = $(this).siblings(".identity").val()
		if (identity != -1) {
			//已选择身份 判断这个人是否存在
			var author = $(this).val();
			if(author != ''){
				isAuthor(identity, author, $(this));
			}		
		} else {
			return;
		}
	})

	// 切换身份input框清空
	$('.member-tr').on('change', '.identity', function() {
		$(this).next().val('');
	})

	// 判断是否存在
	function isAuthor(identity, author, obj) {
		$.ajax({
			type: "POST",
			url: getRootPath() + "/Admin/User/is_author",
			data: {
				identity: identity,
				author: author
			},
			dataType: "json",
			success: function(data) {
				console.log('isAuthor success', data)
				if (data.v == true) {
					obj.next().val(data.remark);
					if(identity == 1 || identity == 2){
						obj.next().next().val(data.status);
					}else{
						obj.next().val(data.status);
					}
				} else {
					// 不存在
					swal({
						title: "提示",
						text: "该人员不存在，请添加信息",
						type: "warning",
						showCancelButton: false,
						closeOnConfirm: true,
						confirmButtonText: "确定",
						confirmButtonColor: "#ec6c62"
					}, function(isConfirm) {
						if (isConfirm) {
							// 当前点击元素的索引，赋到按钮上相对应以偏保存完成给author-id赋值
							var index = $('.member-tr-in .author_name').index(obj);
							$('.edit-mask').show();
							obj.val("")
							if (identity == '1') {
								$('.teacher-msg .save-btn1')[0].setAttribute('data-index', index);
								$('.teacher-msg').show();
								$('.student-msg').hide();
								$('.outside-teacher-msg').hide();
							} else if (identity == '2') {
								$('.student-msg .save-btn2')[0].setAttribute('data-index', index);
								$('.teacher-msg').hide();
								$('.student-msg').show();
								$('.outside-teacher-msg').hide();
							} else if (identity == '3') {
								$('.outside-teacher-msg .save-btn3')[0].setAttribute('data-index', index);
								$('.teacher-msg').hide();
								$('.student-msg').hide();
								$('.outside-teacher-msg').show();
							}
						}

					});
				}

			},
			error: function(data) {
				console.log('isAuthor error', data)
			}
		});
	}

	function cancleEdit() {
		// 教师
		$('#username_t').val("");
		$('#personnel_dept_t').val("");
		$('#usercode_t').val("");
		$('#phone_t').val("");
		$('#title_t').val("");
		$('#dept_name_t').val("-1");
		$('#academic_background_t').val("-1");
		$('#talent_title_t').val("");
		$('#max_xl_t').val("");
		$('#max_xw_t').val("");
		$('#graduate_school_t').val("");
		$('#sex_t').val("-1");
		$('#birthday_t').val("");
		$('#research_direction_t').val("");
		// 学生
		$('#username_s').val("");
		$('#major_s').val("");
		$('#grade_s').val("");
		$('#class_s').val("");
		$('#usercode_s').val("");
		$('#phone_s').val("");
		$('#dept_name_s').val("-1");
		$('#sex_s').val("-1");
		$('#birthday_s').val("");
		$('#research_direction_s').val("");
		// 校外老师
		$('#username-o').val("");
		$('#usercode-o').val("");
		$('#dept_name_o').val("");

		$('.edit-mask').hide();
		$('.teacher-msg').hide();
		$('.student-msg').hide();
		$('.outside-teacher-msg').hide();
	}

	// 填写校验
	var demoT;
	var demoS;
	demoT = $("#editTeacherForm").Validform({
		tiptype: 3
	});
	demoS = $("#editStudentForm").Validform({
		tiptype: 3
	});
	demoO = $("#editOutsideTeacherForm").Validform({
		tiptype: 3
	});


	// 人员信息保存
	function saveEdit(identity) {
		//1教师 2学生 3校外老师
		var data = {};
		if (identity == 1) {
			if (!demoT.check()) {
				$('.Validform_error:first').focus();
				return;
			}
			if ($('#dept_name_t').find('option:selected').val() == -1) {
				window.parent.topMessagePrompt('error', "请选择所属单位");
				return;
			} else if ($('#academic_background_t').find('option:selected').val() == -1) {
				window.parent.topMessagePrompt('error', "请选择学科背景");
				return;
			}
			data = {
				username: $('#username_t').val(),
				personnel_dept: $('#personnel_dept_t').val(),
				usercode: $('#usercode_t').val(),
				phone: $('#phone_t').val(),
				title: $('#title_t').val(),
				dept_name: $('#dept_name_t').val(),
				academic_background: $('#academic_background_t').val(),
				talent_title: $('#talent_title_t').val(),
				max_xl: $('#max_xl_t').val(),
				max_xw: $('#max_xw_t').val(),
				graduate_school: $('#graduate_school_t').val(),
				sex: $('#sex_t').find('option:selected').val(),
				birthday: $('#birthday_t').val(),
				research_direction: $('#research_direction_t').val(),
				type: identity
			}
		} else if (identity == 2) {
			if (!demoS.check()) {
				$('.Validform_error:first').focus();
				return;
			}
			if ($('#dept_name_s').find('option:selected').val() == -1) {
				window.parent.topMessagePrompt('error', "请选择所属单位");
				return;
			}
			data = {
				username: $('#username_s').val(),
				major: $('#major_s').val(),
				grade: $('#grade_s').val(),
				class: $('#class_s').val(),
				usercode: $('#usercode_s').val(),
				phone: $('#phone_s').val(),
				dept_name: $('#dept_name_s').val(),
				sex: $('#sex_s').find('option:selected').val(),
				birthday: $('#birthday_s').val(),
				research_direction: $('#research_direction_s').val(),
				type: identity
			}
		} else if (identity == 3) {
			if (!demoO.check()) {
				$('.Validform_error:first').focus();
				return;
			}
			data = {
				username: $('#username_o').val(),
				usercode: $('#usercode_o').val(),
				dept_name: $('#dept_name_o').val(),
				type: identity
			}
		}
		var author = data.username
		var usercode = data.usercode
		$.ajax({
			type: "POST",
			url: getRootPath() + "/Admin/User/save",
			data: data,
			dataType: "json",
			success: function(data) {
				console.log('saveEdit111 success', data)
				if (data.status == true) {
					swal({
						title: "提示",
						text: data.msg,
						type: "warning",
						showCancelButton: false,
						closeOnConfirm: true,
						confirmButtonText: "确定",
						confirmButtonColor: "#ec6c62"
					}, function(isConfirm) {
						if (isConfirm) {
							if (identity == 1) {
								var index = $('.teacher-msg .save-btn1')[0].getAttribute('data-index')
							} else if (identity == 2) {
								var index = $('.student-msg .save-btn2')[0].getAttribute('data-index')
							} else if (identity == 3) {
								var index = $('.outside-teacher-msg .save-btn3')[0].getAttribute('data-index')
							}
							$('.edit-mask').hide();
							if(identity == 1 || identity == 2){
								$('.member-tr-in').eq(index).find('.author').val(usercode)
								$('.member-tr-in').eq(index).find('.author_name').val(author)
								$('.member-tr-in').eq(index).find('.author-id').val(data.v)
								// $('.member-tr .author').eq(index).val(usercode)
								// $('.member-tr .author_name').eq(index).val(author)
								// $('.member-tr .author-id').eq(index).val(data.v);
							}else{
								$('.member-tr-in').eq(index).find('.author_name').val(author)
								$('.member-tr-in').eq(index).find('.author-id').val(data.v)
								// $('.member-tr .author').eq(index).val(author)
								// $('.member-tr .author-id').eq(index).val(data.v);

							}
							
							cancleEdit();
						}
					});
				} else {
					swal({
						title: "提示",
						text: data.msg,
						type: "warning",
						showCancelButton: false,
						closeOnConfirm: true,
						confirmButtonText: "确定",
						confirmButtonColor: "#ec6c62"
					});
				}
			},
			error: function(data) {
				console.log('saveEdit error', data)
			}
		});
	}


	// function show() {
	// 	var showFileName = $(".showFileName").text();
	// 	if (showFileName != '') {
	// 		$(".icon-remove-sign").show();
	// 	} else {
	// 		$(".icon-remove-sign").hide();
	// 	}

	// }
</script>

</html>